<!DOCTYPE html>
<html lang="en" class="x-admin-sm" xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<title>Edit AfterSaleService</title>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<link rel="stylesheet" th:href="@{/css/font.css}">
<link rel="stylesheet" th:href="@{/css/xadmin.css}">
<script type="text/javascript" th:src="@{/lib/layui/layui.js}"
	charset="utf-8"></script>
<script type="text/javascript" th:src="@{/js/xadmin.js}"></script>
</head>
<body>
<div class="layui-fluid">
		<div class="layui-row">
			<form class="layui-form">
				<div class="layui-form-item" style="display: none">
					<label for="indentDetailNo" class="layui-form-label"> <span
						class="x-red">*</span>订单编号
					</label>
					<div class="layui-input-inline">
						<input type="text" id="indentDetailNo"
							name="indentDetailNo" required="" lay-verify="indentDetail" autocomplete="off" class="layui-input"
							th:value="${indentDetail.indentDetailNo}">
					</div>
				</div>

				<div class="layui-form-item">
					<label for="indentNo" class="layui-form-label">订单编号</label>
					<div class="layui-input-inline" style="width: 66%;">
						<select  name="indent.indentNo" id="indentNo" lay-verify="required">
							<option th:value="${indentDetail.indent.indentNo}">[[${indentDetail.indent.indentNo}]]</option>
						</select>
					</div>
				</div>

				<div class="layui-form-item">
					<label for="goodsNo" class="layui-form-label">商品编号</label>
					<div class="layui-input-inline" style="width: 66%;">
						<select  name="goods.goodsNo" id="goodsNo" lay-verify="required">
							<option th:value="${indentDetail.goods.goodsNo}">[[${indentDetail.goods.goodsNo}]]</option>
						</select>
					</div>
				</div>

				<div class="layui-form-item">
					<label for="indentPrice" class="layui-form-label">
						<span class="x-red">*</span>订单总价
					</label>
					<div class="layui-input-inline">
						<input type="text" id="indentPrice"
							name="indentPrice" required=""
							lay-verify="indentPrice" autocomplete="off"
							class="layui-input"
							th:value="${indentDetail.indentPrice}">
					</div>
				</div>
				<div class="layui-form-item">
					<label for="indentAccount" class="layui-form-label">
						<span class="x-red">*</span>订单总价
					</label>
					<div class="layui-input-inline">
						<input type="text" id="indentAmount"
							name="indentAccount" required=""
							lay-verify="indentAccount" autocomplete="off"
							class="layui-input"
							th:value="${indentDetail.indentAccount}">
					</div>
				</div>

				<div class="layui-form-item">
					<label for="L_repass" class="layui-form-label"></label>
					<button id="L_repass" class="layui-btn" lay-filter="edit"
						lay-submit="">修改</button>
				</div>
			</form>
		</div>
	</div>


	<script type="text/javascript">
		layui.use([ 'form', 'layedit', 'laydate' ,'jquery'], function() {
				$ = layui.jquery;
				var form = layui.form, layer = layui.layer, layedit = layui.layedit, laydate = layui.laydate;
				
				$.get("/indentDetail/indentList",{},function (data) {
					var list = data;
					var select = document.getElementById('indentNo');
					if (list != null || list.size() > 0) {
						for (var c in list) {
							var option = document.createElement("option");
							option.setAttribute("value", list[c].indentNo);
							option.innerText = list[c].indentNo;
							select.appendChild(option)
						}
					}
					form.render('select');
				},"json");
				
				$.get("/indentDetail/goodsList",{},function (data) {
					var list = data;
					var select = document.getElementById('goodsNo');
					if (list != null || list.size() > 0) {
						for (var c in list) {
							var option = document.createElement("option");
							option.setAttribute("value", list[c].goodsNo);
							option.innerText = list[c].goodsNo;
							select.appendChild(option)
						}
					}
					form.render('select');
				},"json");
				//监听提交
				form.on('submit(edit)', function(data) {
					console.log(data.field)
					$.ajax({
						url : "/indentDetail/edit",
						method : 'post',
						data : data.field,
						dataType : 'JSON',
						success : function(res) {
							if (res.code === 0) {
								//弹出提示，并在1秒后进行跳转
								layer.alert("修改成功", {
									icon : 6
								}, function() {
									//关闭当前frame
									xadmin.close();
									// 可以对父窗口进行刷新
									xadmin.father_reload();
									return false;
								});
							} else {
								layer.msg("修改失败:" + res.msg);
								return false;
							}
						}
					});
					return false;
				});
			})
	</script>


	

</body>
</html>